/**
 * @Author @fiber-cloud
 * @Date 2025/7/27 15:12
 */
public class Test {

    //合并两个链表
    public MySingleList.ListNode mergeTwoLists(MySingleList.ListNode list1, MySingleList.ListNode list2) {
        MySingleList.ListNode nHead = new MySingleList.ListNode(-1);
        MySingleList.ListNode tmp = nHead;

        while (list1 != null && list2 != null){
            if (list1.val < list2.val){
                tmp.next = list1;
                list1 = list1.next;

            }else {
                tmp.next = list2;
                list2 = list2.next;
            }
            tmp = tmp.next;

            if (list1 != null) {
                tmp.next = list1;
            }
            if (list2 != null) {
                tmp.next = list2;
            }
        }
        return nHead.next;
    }


    public static void main1(String[] args) {
        MySingleList l1 = new MySingleList();
        MySingleList l2 = new MySingleList();

    }


    //测试双向链表
    public static void main(String[] args) throws IndexWrongFulException {
        MyLinkedList myLinkedList = new MyLinkedList();
//        myLinkedList.addFirst(1);
//        myLinkedList.addFirst(2);
//        myLinkedList.addFirst(3);
//        myLinkedList.addFirst(4);
//        myLinkedList.addFirst(5);
//        myLinkedList.addFirst(6);
        myLinkedList.addLast(1);
        myLinkedList.addLast(2);
        myLinkedList.addLast(3);
        myLinkedList.addLast(4);
        myLinkedList.addLast(5);
        myLinkedList.addLast(5);
        myLinkedList.addLast(3);
        myLinkedList.addLast(2);
        myLinkedList.addLast(5);
        myLinkedList.removeAllKey(5);

        myLinkedList.addIndex(1,7);
        boolean sum = myLinkedList.contains(2);
        myLinkedList.remove(3);
        System.out.println(sum);
        myLinkedList.display1();
    }

}
